process.env.NODE_ENV = "development";
const { merge } = require("webpack-merge");
const commonConfig = require("./webpack.common");
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");

let _devConfig = {
  mode: "development",
  stats: "errors-warnings",
  devtool: "cheap-module-source-map",
  devServer: {
    open: true,
    port: 8082,
    proxy: {
      "/api/": {
        // ws: true, //如果要代理 websockets，配置这个参数
        // changeOrigin: true, //是否跨域
        // secure: false, // 如果是https接口，需要配置这个参数
        //使用本地mock
        target: "http://localhost:3000",
        pathRewrite: { "^/api": "/mock" },
      },
    },
    client: {
      logging: "error",
    },
  },
  plugins: [new ReactRefreshWebpackPlugin()],
};

let devConfig = merge(commonConfig, _devConfig);

module.exports = devConfig;
